<?php

/*

	$type  
		"redirect"  : will redirct to the page name defined in the $param (admin page)
		"id"		: only sets the id with name defined in the $param

*/

class spButton extends spInput
{
	//public function __construct( $title, $type, $param, $disabled=false )
	public function __construct( $param )
	{
		// required
		$title 		= $param["title"];
		
		// optional (some are dependent on the "type")
		$type 		= isset($param["type"])?$param["type"]:"";
		$id			= isset($param["id"])?$param["id"]:"";
		$page		= isset($param["page"])?$param["page"]:"";
		$url		= isset($param["url"])?$param["url"]:"";
		$callback	= isset($param["callback"])?$param["callback"]:"";
		$disabled	= isset($param["disabled"])?$param["disabled"]:false;
		$class		= isset($param["class"])?$param["class"]:"";
		$name		= isset($param["name"])?$param["name"]:"";
	
		parent::__construct();
		parent::setType( "submit" );
		parent::setValue( $title );
		
		if ( $name!="" )
		{
			parent::setName( $name );
		}
		
		switch ( $type )
		{
			case "callback":
				parent::setClass( "spCallback" );
				parent::setName( $callback );
				break;
		
			case "redirect_admin":
				parent::setClass( "spRedirectAdmin" );
				parent::setName( $page );
				break;

			case "redirect_url":
				parent::setClass( "spRedirectUrl" );
				parent::setName( $url );
				break;
				
			case "id":
				{
					parent::addAttr( "id", $id );	
				}
				break;
		}
		
		if ( $disabled )
			parent::addAttr( "disabled", "disabled" );		
			
		if ( $id!="" )
			parent::setId( $id );	

		if ( $class!="" )
			parent::setClass( $class );
			
		if ( isset($param["attr"]) )
			parent::addAttrArray( $param["attr"] );
	}
	
	public function render( $indent=0 )
	{
		parent::render( $indent );
	}
}

?>